home *** CD-ROM | disk | FTP | other *** search
/ BMUG PD-ROM A / PD-ROM A.iso / Utility / Random / DarkSide 2.5 / FaderShell / Blackout.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-28  |  5.1 KB  |  127 lines  |  [TEXT/MPS ]

  1. #ifndef __OSUTILS__
  2.     #include <OSUtils.h>
  3. #endif
  4. #include <QDOffscreen.h>
  5.  
  6. /* ------------------------------------------------------------------------------------    */
  7. /*    The following routines are used to help implement a blackout */
  8. /* ------------------------------------------------------------------------------------    */
  9.  
  10. // Returns a value from 0 to max-1
  11. short    Rnd(long max);
  12.  
  13. // Places a rectangle on one of the screens at random.  Rect is within screen bounds
  14. void PlaceRectOnScreen(
  15.     short width,            // width of rect, can be 0
  16.     short height,            // height of rect, can be 0
  17.     Rect * placedRect,        // Placed rect is returned here
  18.     Rect * margins,            // margins around screen, can be nil
  19.     Rect * screenBound);    // placed screen bounds returned here, can be nil
  20.     
  21. // Handy offscreen pixmap type routines
  22. void MyNewGWorld(GWorldPtr *offscreenGWorld,short PixelDepth,Rect *boundsRect,
  23.             CTabHandle cTable,GDHandle aGDevice,GWorldFlags flags);
  24. void MyDisposeGWorld (GWorldPtr offscreenGWorld);
  25. void MySetGWorld(GWorldPtr offscreenGWorld);
  26. void MyLockPixels(GWorldPtr offscreenGWorld);
  27. void MyUnlockPixels(GWorldPtr offscreenGWorld);
  28. Ptr  MyGetPixBaseAddr(PixMapHandle portPixMap);
  29.  
  30. /* ------------------------------------------------------------------------------------    */
  31. /*    The following structure is used for setups                                            */
  32. /* ------------------------------------------------------------------------------------    */
  33. #define kSetupDialogID        10000
  34. #define kSettingsID            10000
  35. #define kSettingsType        'FSET'
  36.  
  37. typedef struct
  38.     {
  39.     ModalFilterProcPtr        okCancelFilterProc;
  40.     
  41.     ProcPtr        defaultUserItem;
  42.     ProcPtr        roundRectUser;
  43.     ProcPtr        aboutUserItem;
  44.     
  45.     ProcPtr        setUserItem;
  46.     ProcPtr        getItemCtlValue;
  47.     ProcPtr        setItemCtlValue;
  48.     ProcPtr        getClusterValue;
  49.     ProcPtr        setClusterValue;
  50.     ProcPtr        setLabeledCtlValue;
  51.     ProcPtr        setItemString;
  52.     ProcPtr        getItemString;
  53.     ProcPtr        getItemRect;
  54.     ProcPtr        centerWindow;
  55.     } SetupParamBlock;
  56.     
  57. #define OKCancelFilterProc    (*theSetup->okCancelFilterProc)
  58.     // standard filter proc for command-. and return/enter key
  59.     
  60. #define DefaultUserItem        (*theSetup->defaultUserItem)
  61.     // A user item for filling a useritem with a rounded rect for default buttons
  62. #define RoundRectUser        (*theSetup->roundRectUser)
  63.     // A user item for thin rounded rects
  64.  
  65. #define AboutUserItem        (*theSetup->aboutUserItem)
  66.     // A user item for drawing STR 10000 in 9 point applFont
  67.  
  68. #define SetUserItem            (*theSetup->setUserItem)
  69.     // For setting a given item's userItem proc : SetUserItem(dPtr, item, proc);
  70.     
  71. #define GetItemCtlValue        (*theSetup->getItemCtlValue)
  72.     // Returns an item's control value : value = GetItemCtlValue(dPtr, item);
  73.     
  74. #define SetItemCtlValue        (*theSetup->setItemCtlValue)
  75.     // Sets an item's control value : SetItemCtlValue(dPtr, item, value);
  76.     
  77. #define GetClusterValue        (*theSetup->getClusterValue)
  78.     // Gets a value for a cluster of controls, 0 = first control value = GetClusterValue(dPtr, min, max);
  79.     
  80. #define SetClusterValue        (*theSetup->setClusterValue)
  81.     // Sets the value for a cluster of controls, SetClusterValue(dPtr, min, max, value);
  82.     
  83. #define SetLabeledCtlValue    (*theSetup->setLabeledCtlValue)
  84.     // the value of a control, and a tag string on another item: SetLabeleCtlValue(dPtr, item, labelStaticItem, value);
  85.     
  86. #define SetItemString        (*theSetup->setItemString)
  87.     // Sets the string of an item, SetItemString(dPtr, item, string);
  88.     
  89. #define GetItemString        (*theSetup->getItemString)
  90.     // Gets the string of an item, GetItemString(dPtr, item, string);
  91.  
  92. #define GetItemRect        (*theSetup->getItemRect)
  93.     // gets the rectangle of, GetItemRect(dPtr, item, *theRect);
  94.  
  95. #define CenterWindow        (*theSetup->centerWindow)
  96.     // centers a WIND or DLOG template, CenterWindow(ResType theType, short resID, 
  97.     //    Point * wherePlaced) - wherePlaced may be nil
  98.  
  99.  
  100. /* ------------------------------------------------------------------------------------    */
  101. /*    The following routines are in the Blackout.  Change them to implement various displays.*/
  102. /* ------------------------------------------------------------------------------------    */
  103.  
  104. BlackoutHandle    PreflightBlackout(long * minSleepTime, long * maxSleepTime);
  105. Boolean            InitBlackout(BlackoutHandle theBlackout, WindowPtr blackoutWindow);
  106. void            BlackoutIdle(WindowPtr blackoutWindow, BlackoutHandle theBlackout);
  107. Boolean            BlackoutEvent(EventRecord *theEvent);
  108. void            DisposeBlackout(BlackoutHandle theBlackout);
  109.  
  110. /* ------------------------------------------------------------------------------------    */
  111. /*    Useful macros for your fader                                                         */
  112. /* ------------------------------------------------------------------------------------    */
  113. #define TopLeft(aRect)    (* (Point *) &(aRect).top)
  114. #define BotRight(aRect)    (* (Point *) &(aRect).bottom)
  115. #define RectWidth(r) (short)((r)->right - (r)->left)
  116. #define RectHeight(r) (short)((r)->bottom - (r)->top)
  117.  
  118. /* ------------------------------------------------------------------------------------    */
  119. /*    The following globals are useful information about the Mac                             */
  120. /* ------------------------------------------------------------------------------------    */
  121. #ifndef INMAINBLACKOUT
  122.     extern SysEnvRec    theEnvirons;
  123. #endif
  124.  
  125. // Faders should be in the main segment by default
  126. #pragma segment Main
  127.